<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>5-0</title>
</head>
<body>
<h1>修改商品页面</h1>
<div>
    <input v-model="product.id" type="text" placeholder="商品编号" readonly>
    <input v-model="product.title" type="text" placeholder="商品标题">
    <input v-model="product.price" type="text" placeholder="商品价格">
    <input v-model="product.saleCount" type="text" placeholder="商品销量">
    <input type="button" value="修改" @click="update()">
</div>
<script src="js/vue.js"></script>
<script src="js/axios.min.js"></script>
<script>
    let v = new Vue({
        el:"div",
        data:{
            product:{}
        },
        created:function () {
            let id = location.search.split("=")[1]
            axios.get("/selectById?id="+id).then(function (response) {
                v.product=response.data;
            })
        },
        methods:{
            update () {
                axios.post("/update",v.product).then(function () {
                    alert("商品数据已修改");
                    location.href="/list.html";
                })
            }
        }
    })
</script>
</body>
</html>